# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Aaron DeVore <aaron.devore@gmail.com>

pkgname=xsv
pkgver=0.13.0
pkgrel=2
pkgdesc="A CLI for indexing, slicing, analyzing, splitting and joining CSV files"
arch=('loong64' 'x86_64')
url="https://github.com/BurntSushi/xsv"
license=('Unlicense' 'MIT')
depends=('gcc-libs')
makedepends=('git' 'rust')
_commit='2b4cbaa0eecf7b507a612632fe00289b1b358c15'
source=("git+$url.git#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd xsv

  git describe --tags
}

prepare() {
  cd xsv

  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd xsv

  cargo build --frozen --release
}

check() {
  cd xsv

  cargo test --frozen --release
}

package() {
  cd xsv

  # binary
  install -vDm755 -t "$pkgdir/usr/bin" target/release/xsv

  # documentation
  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" README.md
  # licenses
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" ./*LICENSE*
}
